<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/in.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-CN">
<head>
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>修改生日</title>
    <link rel="stylesheet" href="${staticPage}/css/weui.css"/>
    <link rel="stylesheet" href="${staticPage}/css/modifyName.css"/>
    <!--<link rel="stylesheet" href="css/example.css"/>-->
</head>
<script type="text/javascript">

	var formatDate = function (date) {  
	    var y = date.getFullYear();  
	    var m = date.getMonth() + 1;  
	    m = m < 10 ? '0' + m : m;  
	    var d = date.getDate();  
	    d = d < 10 ? ('0' + d) : d;  
	    return y + '-' + m + '-' + d;  
	};  
    


	function showToast(){
		 $('#toast').show();
	 setTimeout(function () {
	     $('#toast').hide();
	     location.href="${ctx}/myInfo1.0.do";
	 }, 2000);
	}

	$(function(){
		
		var  data1=new Date("${current_user.birth}");   
		if(data1=="Invalid Date"){
			$("input[name='birth']").val(formatDate(new Date()));
		}else{
			$("input[name='birth']").val(formatDate(data1));
		}
		
		
		
		$("#modifyButton").click(function(){
			
		// 	var realname=$("input[name='realname']").val();
		// 	var tel=$("input[name='tel']").val();
			var birth=$("input[name='birth']").val();
		//		var code=$("input[name='code']").val();
		//		var sessionId=$("input[name='sessionId']").val();
			 if(birth==""||birth==null){
				alert("生日不能为空！");
				}
			else{
				$.getJSON("${ctx}/user_modifyInfo.json",
						{birth:birth},
				function(json){
					if(json.success){
						showToast();
					}
					else{
						alert(json.msg);
						}
				})
				}
		});
	})
</script>
<body>

     <!-- <div style="background-color: #ffffff;width: 80%;height: 40px;margin-left: 10%;margin-top: 20px;border: none">
        <div class="weui_cell">
            <div class="weui_cell_hd" style="width: 60px !important;"><label for="" class="weui_label">生日</label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <input class="weui_input" type="date" value="" name="birth"/>
            </div>
        </div>

    </div> -->
    <div class="weui_cells weui_cell_form" style="margin-left:10%;margin-right:10%">
     <div class="weui_cell">
            <!-- <div class="weui_cell_hd"><label for="" class="weui_label">生日</label></div> -->
            <div class="weui_cell_bd weui_cell_primary"  style="margin-left:31%;margin-right:15%">
                <input class="weui_input" type="date" value="" name="birth"   />
            </div>
        </div>
        </div>
    
    <div class="weui_btn_area submitButton">
        <a class="weui_btn weui_btn_primary"  id="modifyButton">保存</a>
    </div>
    <div id="toast" style="display: none;">
            <div class="weui_mask_transparent"></div>
            <div class="weui_toast">
                <i class="weui_icon_toast"></i>
                <p class="weui_toast_content">修改成功！</p>
            </div>
     </div>
     
</body>
</html>